// pages/son/son.js
Page({
  /**
   * 页面的初始数据
   */

  data: {
    slides: [],
    choice: [],
    imgid: [],
    textid: [],
    tiemid:[],
    starIndex: [1, 1, 1, 1, 1],
    animationData:{},
    disp: "none",
    txtone: [{
        id: 1,
        inmag: '../../assets/Aries.png',
        text: '白羊座',
        time: '3.21-4.19',
        transmit: 'baiyang'
      },
      {
        id: 4,
        inmag: '../../assets/Cancer.png',
        text: '巨蟹座',
        time: '6.22-7.22',
        transmit: 'juxie'
      },
      {
        id: 7,
        inmag: '../../assets/Libra.png',
        text: '天秤座',
        time: '9.23-10.23',
        transmit: 'tiancheng'
      },
      {
        id: 10,
        inmag: '../../assets/Capricorn.png',
        text: '摩羯座',
        time: '12.22-1.19',
        transmit: 'mojie'
      },
      {
        id: 2,
        inmag: '../../assets/Taurus.png',
        text: '金牛座',
        time: '4.20-5.20',
        transmit: 'jinniu'
      },
      {
        id: 5,
        inmag: '../../assets/Leo.png',
        text: '狮子座',
        time: '7.23-8.22',
        transmit: 'shizi'
      },
      {
        id: 8,
        inmag: '../../assets/Scorpio.png',
        text: '天蝎座',
        time: '10.24-11.22',
        transmit: 'tianxie'
      },
      {
        id: 11,
        inmag: '../../assets/Aquarius.png',
        text: '水瓶座',
        time: '1.20-2.18',
        transmit: 'shuiping'
      },
      {
        id: 3,
        inmag: '../../assets/Gemini.png',
        text: '双子座',
        time: '5.21-6.21',
        transmit: 'shuangzi'
      },
      
      
      {
        id: 6,
        inmag: '../../assets/Virgo.png',
        text: '处女座',
        time: '8.23-9.22',
        transmit: 'chunv'
      },
      
      
      {
        id: 9,
        inmag: '../../assets/Sagittarius.png',
        text: '射手座',
        time: '11.23-12.21',
        transmit: 'sheshou'
      },
      
      
      {
        id: 12,
        inmag: '../../assets/Pisces.png',
        text: '双鱼座',
        time: '2.19-3.20',
        transmit: 'shuangyu'
      }
    ],
    txt: [{
      id: 1,
      inmag: '../../assets/Aries.png',
      text: '白羊座',
      time: '3.21-4.19',
      transmit: 'baiyang'
    },
    {
      id: 2,
      inmag: '../../assets/Taurus.png',
      text: '金牛座',
      time: '4.20-5.20',
      transmit: 'jinniu'
    },
    {
      id: 3,
      inmag: '../../assets/Gemini.png',
      text: '双子座',
      time: '5.21-6.21',
      transmit: 'shuangzi'
    },
    {
      id: 4,
      inmag: '../../assets/Cancer.png',
      text: '巨蟹座',
      time: '6.22-7.22',
      transmit: 'juxie'
    },
    {
      id: 5,
      inmag: '../../assets/Leo.png',
      text: '狮子座',
      time: '7.23-8.22',
      transmit: 'shizi'
    },
    {
      id: 6,
      inmag: '../../assets/Virgo.png',
      text: '处女座',
      time: '8.23-9.22',
      transmit: 'chunv'
    },
    {
      id: 7,
      inmag: '../../assets/Libra.png',
      text: '天秤座',
      time: '9.23-10.23',
      transmit: 'tiancheng'
    },
    {
      id: 8,
      inmag: '../../assets/Scorpio.png',
      text: '天蝎座',
      time: '10.24-11.22',
      transmit: 'tianxie'
    },
    {
      id: 9,
      inmag: '../../assets/Sagittarius.png',
      text: '射手座',
      time: '11.23-12.21',
      transmit: 'sheshou'
    },
    {
      id: 10,
      inmag: '../../assets/Capricorn.png',
      text: '摩羯座',
      time: '12.22-1.19',
      transmit: 'mojie'
    },
    {
      id: 11,
      inmag: '../../assets/Aquarius.png',
      text: '水瓶座',
      time: '1.20-2.18',
      transmit: 'shuiping'
    },
    {
      id: 12,
      inmag: '../../assets/Pisces.png',
      text: '双鱼座',
      time: '2.19-3.20',
      transmit: 'shuangyu'
    }
    ],
    select:0
  },

  month: function() {
    this.setData({ 
      choice: this.slides.month,
      select: 3
    })
  },
  day: function() {
    this.setData({
      choice: this.slides.day,
      select: 0
    })
  },
  tomorrow: function() {
    this.setData({
      choice: this.slides.tomorrow,
      select: 1,
    })
  },
  week: function() {
    this.setData({
      choice: this.slides.week,
      select: 2,
    })
  },
  year: function() {
    this.setData({
      choice: this.slides.year,
      select: 4
    })
  },
  onShow() {
    const animation = wx.createAnimation({
      duration: 1000,
      timingFunction: 'ease',
    })
    this.animation = animation

    animation.scale(2, 2).rotate(45).step()

    this.setData({
      animationData: animation.export()
    })

    setTimeout(function () {
      animation.translate(30).step()
      this.setData({
        animationData: animation.export()
      })
    }.bind(this), 100000)
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this;
    console.log(options.timeid)
    wx.request({
      url: "https://ali-star-lucky.showapi.com/star?needMonth=1&needTomorrow=1&needWeek=1&needYear=1&star=" + options.cat,
      header: {
        'Content-Type': 'json',
        'Authorization': 'APPCODE d6382e66479d42c7911d9d179b7a301d'
      },
      success: res => {
        // this.setData({ slides: res.data.showapi_res_body })

        // this.setData({
        //   aid:1
        // })

        this.slides = res.data.showapi_res_body
        that.slides = res.data.showapi_res_body
        console.log(res)
        that.setData({
          choice: that.slides.day
        })
        console.log(options)
        that.setData({
          imgid: options.imgid
        })
        that.setData({
          textid: options.textid
        })
        that.setData({
          timeid:options.timeid
        })
      },
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
  
  },
  

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  },


  show: function() {
    this.setData({
      disp: "block"
    })
  },
  hide: function() {
    this.setData({
      disp: "none"
    })
  }

})